<?php 
if (isset($_GET['email']) && isset($_GET['password'])) {
	$email = $_GET['email'];
	$password = $_GET['password'];
} else {
	$response["login"] = "Invalid login data";
	exit ;
}

$userid = getUserId($email, $password);
if ($userid == -1) {
	$response["login"] = "failed";
} else {
	$response["login"] = "successful";
}
$response["userid"] = $userid;
echo json_encode($response);

function getUserId($email, $password) {
	mysql_connect("localhost", "web964", "pass17") or die("Connection failed.");
	mysql_select_db("usr_web964_1") or die("Database does not exist.");
	$result = mysql_query("SELECT id FROM users WHERE email='$email' AND password='$password'");
	if (mysql_num_rows($result) == 0) {
		return -1;
	}
	while ($row = mysql_fetch_object($result)) {
		$userid = $row -> id;
	}
	return $userid;
}
?>